Skip to main content
Glama
hyperspell

hyperspell-mcp

Official
by hyperspell

Get Collection

Retrieve all documents from a specified collection to access and manage your unstructured data through the Hyperspell MCP server.

Instructions

Get a list of all documents in a collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_nameYes

Implementation Reference

  • The handler function that executes the logic for the 'Get Collection' tool. It lists all documents in the specified collection using the Hyperspell API and converts them to Document objects.
    def get_documents(collection_name: str) -> list[Document]: """Get a list of all documents in a collection""" r = mcp.api.documents.list(collection=collection_name) return Document.from_pydantic(r.items)
  • Pydantic-compatible dataclass defining the schema for Document objects returned by the 'Get Collection' tool.
    class Document(BaseModel): id: int title: str type: str summary: str
  • Decorator that registers the get_documents handler as the 'Get Collection' tool (or resource) in the MCP server, based on configuration.
    @mcp.tool_or_resource("collection://{collection_name}", name="Get Collection")
  • Helper method used by Document.from_pydantic to convert API response models to the local dataclass format.
    @dataclass class BaseModel: @overload @classmethod def from_pydantic(cls, model: PydanticBaseModel) -> Self: ... @overload @classmethod def from_pydantic(cls, model: Sequence[PydanticBaseModel]) -> list[Self]: ... @classmethod def from_pydantic( cls, model: PydanticBaseModel | Sequence[PydanticBaseModel] ) -> Self | list[Self]: """Convert a Pydantic model to a data class, selecting only the keys that are part of the data class.""" if isinstance(model, Sequence): return [cls.from_pydantic(m) for m in model] data = model.model_dump() # Only select the keys in data that are part of this data class data = {key: value for key, value in data.items() if key in cls.__annotations__} return cls(**data)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hyperspell/hyperspell-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server